package com.company._360;

import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        List<Integer> A = new ArrayList<>();
        int[] B = new int[N];
        for(int i = 0; i < N; i++){
            A.add(sc.nextInt());
        }
        int count = 0;
        for(int i = 0; i < N; i++){
            B[i] = sc.nextInt();
            if(i > A.indexOf((B[i]))){
                count++;
            }
        }
        System.out.println(count);
    }

}
